<?php 

session_start();

include '../../function.php';

if(isset($_SESSION['username'])){
	error('已登录，不需要登录','./index.php',2);
	exit;
}

if(empty($_POST['username'])){
		error('用户名没填','./index.php',4);
		exit;
}
if(empty($_POST['password'])){
		error('密码没填','./index.php',4);
		exit;
}


$user = include './user.php';

foreach ($user as $v) {
	if($v['username']==$_POST['username']){
		if($v['password']==md5($_POST['password'])){
			session_start();

			$_SESSION['username']=$v['username'];

			error('登录成功','./index.php',2);
			exit;

		}else{
			error('用户名或密码不正确','./index.php',2);
			exit;
		}
	}
}

error('用户名或密码不正确','./index.php',2);
// 写session

// session_start();

// $_SESSION['username']="zhibinm";








 ?>